/**
 *
 * jcrt and its source-code is licensed under the LGPL.
 * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
 * When copying, adapting, or redistributing this document in keeping with the guidelines above,
 * you are required to provide proper attribution to obinary.
 * If you reproduce or distribute the document without making any substantive modifications to its content,
 * please use the following attribution line:
 *
 * Copyright 2007 Atjava.com Ltd. (http://www.atjava.com) All rights reserved.
 *
 */
package com.atjava.jcrt.logging;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.xml.DOMConfigurator;
/**
 * 
 * @author biggie
 * @version $Revision: 1.3 $ $Date: 2008/08/07 00:52:23 $
 */
public class Log4jInit extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void init() throws ServletException{
		
		String path = this.getServletContext().getRealPath("");
		if(path!=null && path.indexOf("/./")!=1){
			path.replaceAll("/./", "/");
		}

		String projectUrl = this.getServletContext().getRealPath("/");
		String configDir  = this.getServletConfig().getInitParameter("log4j-config");
		DOMConfigurator.configureAndWatch(projectUrl+configDir);
	}
}
